package coroutines.launch.mode

import kotlinx.coroutines.*

class LaunchLazy {
    companion object {
        suspend fun launchLazy(scope:CoroutineScope) : Job {
            return scope.launch(context = Dispatchers.IO, start = CoroutineStart.LAZY) {
                println("launch un dispatched start : ${Thread.currentThread().name}")
                Thread.sleep(2000)
                println("launch un dispatched start delay(1000): ${Thread.currentThread().name}")
                delay(1000)
                println("launch un dispatched delay(1000) end : ${Thread.currentThread().name}")
                println("launch un dispatched end : ${Thread.currentThread().name}")
            }
        }
    }
}

fun main() {
    runBlocking {
        val job = LaunchLazy.launchLazy(this)
        job.start()
    }
}